package cn.sf.sufingcommentconsumer.controller;

import cn.sf.pojo.Comment;
import cn.sf.pojo.Reply;
import cn.sf.sufingcommentconsumer.service.CommentService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@CrossOrigin("*")
public class CommentController implements CommentService {

    @Resource
    private CommentService commentService;

    @Override
    @RequestMapping("/queryCommentAndReply")
    /**
    * @Author: 24629
    * @Time: 2020/8/18 17:47
    * @Description: 查询回复信息，用户信息及以下的回复信息
    * @Param: [videoId]
    * @Return: java.util.List<cn.sf.pojo.Comment>
    */
    public List<Comment> queryCommentAndReply(long videoId) {
        return commentService.queryCommentAndReply(videoId);
    }

    @Override
    @RequestMapping("/addComment")
    /**
    * @Author: 24629
    * @Time: 2020/8/18 17:47
    * @Description: 添加评论信息
    * @Param: [userId, videoId, message, picture]
    * @Return: boolean
    */
    public boolean addComment(long userId, long videoId, String message, String picture) {
        return commentService.addComment(userId, videoId, message, picture);
    }

    @Override
    @RequestMapping("/addReply")
    /**
    * @Author: 24629
    * @Time: 2020/8/18 17:46
    * @Description: 添加回复信息
    * @Param: [reply] 回复信息
    * @Return: boolean
    */
    public boolean addReply(Reply reply) {
        return commentService.addReply(reply);
    }

    @Override
    @RequestMapping("/queryCommentCount")
    /**
    * @Author: 24629
    * @Time: 2020/8/19 11:54
    * @Description: 查询评论数量
    * @Param: [videoId]
    * @Return: int
    */
    public int queryCommentCount(long videoId) {
        return commentService.queryCommentCount(videoId);
    }
}
